import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [createPersistedState()],
  state: {
    token:'',
    userInfo:{},
  },
  getters: {
  },
  mutations: {
    getToken(state,value){
      state.token = value
    },
    changeUserInfo(state,value){
      state.userInfo=value
    }
  },
  actions: {
  async getUser(context){
    const {data:res} = await axios.get('/my/userinfo')
    context.commit('changeUserInfo',res.data)
    }
  },
  modules: {
  }
})
